package com.vitas.coin.ui.dialog;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.vitas.coin.databinding.DialogSimpleInputBinding;

public class NewListDlg extends BaseDialogFragment {

    DialogSimpleInputBinding binding;
    String title;

    public NewListDlg setTitle(String s) {
        title = s;
        return this;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DialogSimpleInputBinding.inflate(inflater, container, false);
        if (!TextUtils.isEmpty(title)) {
            binding.tvTitle.setText(title);
        } else {
            binding.tvTitle.setText("新建铃单");
        }
        binding.tvConfirm.setOnClickListener(v -> {
            dismiss(true, binding.etContent.getText().toString().trim());
        });
        binding.tvCancel.setOnClickListener(v -> dismiss());

        return binding.getRoot();
    }
}
